(* Plots of families of  3D tracejtories *)

(* COPYRIGHT_BEGIN
*  Copyright (c) 1995 János Karsai,
*  Department of Medical Informatics, Albert Szent-Györgyi Medical University
*
* The project is supported by the Foundation for the Hungarian Higher Education and
* Research, Grant No. 776/94 and by the Founfation for the Development of Higher
* Education Grant No. FEFA-IV 1608/4.
*
*)
(*

The functions of this package provide several 2D and 3D  plots of families of 2D trajectories, such as  trajectories of the solutions of the 2D system of differential equations:
		x'=xdot
		y'=ydot
		z'=zdot
with one initial condition or with a list initial conditions.

The parameters

t0		:initial time
T		:final time
Sol		:{x[t],y[t],z[t]}curve in the 3D phasespace
Traj[t]		:List of trajectories of form {{x[t],y[t],z[t]},...} as functions
*)
(*
3D plots
*)
(*
Plot the trajectories
*)

PhasePlot3D[Traj_,t0_,T_,params___]:=
	(ParametricPlot3D[#,{t,t0,T},params,
		AspectRatio->Automatic,
		PlotRange->All,
		PlotLabel->FontForm["The trajectories",
		{"Times-Bold", 12}],
		AxesLabel->{"x","y","z  "}])& [Traj];
(*
Plot the projection of the trajectories
*)
(*XY Projection
*)
PhasePlot3DXY[Traj_,t0_,T_,params___]:=
	(ParametricPlot[#,{t,t0,T},params,
		AspectRatio->Automatic,
		PlotRange->All,
		PlotLabel->FontForm["XY Projection",
		{"Times-Bold", 12}],
		AxesLabel->{"x","y"}])& [
		Traj/.{a_[t],b_[t],c_[t]}->{a[t],b[t]}];
(*
YZ Projection
*)
PhasePlot3DYZ[Traj_,t0_,T_,params___]:=
	(ParametricPlot[#,{t,t0,T},params,
		AspectRatio->Automatic,
		PlotRange->All,
		PlotLabel->FontForm["YZ Projection",
		{"Times-Bold", 12}],
		AxesLabel->{"y","z"}])& [
		Traj/.{a_[t],b_[t],c_[t]}->{b[t],c[t]}];
(*
XZ Projection
*)
PhasePlot3DXZ[Traj_,t0_,T_,params___]:=
	(ParametricPlot[#,{t,t0,T},params,
		AspectRatio->Automatic,
		PlotRange->All,
		PlotLabel->FontForm["XZ Projection",
		{"Times-Bold", 12}],
		AxesLabel->{"x","z"}])& [
		Traj/.{a_[t],b_[t],c_[t]}->{a[t],c[t]}];
(*
PhasePlot Animation
*)

AnimatePhasePlot3D[{xdot_,ydot_,zdot_},Icond_,t0_,T_,
		{pa_,pa0_,pa1_},params___]:=
	AnimatePhasePlot3D[{xdot,ydot,zdot},Icond,t0,T,
				{pa,pa0,pa1,(pa1-pa0)/4},params]
AnimatePhasePlot3D[{xdot_,ydot_,zdot_},Icond_,t0_,T_,
				{pa_,pa0_,pa1_,pad_},params___]:=
Table[PhasePlot3D[
		Function[t,DeSol3DTab[{xdot,ydot,zdot},
		Icond,t0,T]],t0,T,params,
		PlotLabel->"Step:"ToString[pa]],{pa,pa0,pa1,pad}];


(*
Plot of the i-th coord. of the solutions
*)
SolCoordPlot[Traj_,t0_,T_,Icoord_,opt___]:=
	(Plot[#,{t,t0,T},opt, 
	 	PlotLabel->FontForm[ "The solution, coordinate"
	 	ToString[Icoord],{"Times-Bold", 12}
		 ]] & )[Transpose[Traj[t]][[Icoord]]]
(*
Plot of all coord.-s of one solution in graph. array
*)
SolPlot[Sol_List,t0_,T_,opt___]:=
	Show[GraphicsArray[
		Partition[Map[(Plot[Sol[[#]],{t,t0,T},opt,
			PlotLabel->FontForm["Coordinate" 
			ToString[#],{"Times",11}],
			DisplayFunction->Identity])&,#]&[
			Table[i,{i,1,Length[Sol],1}]],Length[Sol]]]
			,DisplayFunction->$DisplayFunction]

(*
Plots every soln. in Traj[t] in graph. array
*)


SolPlotTab[Traj_,t0_,T_,Opt___]:=
		Map[SolPlot[#,t0,T,Opt]&,#] &[Traj]

